#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
// 统计词频
class Solution
{
public:
    int singleNumber(vector<int> &nums)
    {
        unordered_map<int, int> u_map;
        for (auto e : nums)
        {
            ++u_map[e];
        }
        for (auto e : u_map)
        {
            if (e.second == 1)
                return e.first;
        }
        return -1;
    }
};
// 排序+双指针
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution
{
public:
    int singleNumber(vector<int> &nums)
    {
        sort(nums.begin(), nums.end());
        int i = 0, j = 1;
        if (nums.size() == 1)
            return nums[0];
        while (j < nums.size())
        {
            if (nums[i] != nums[j])
                return nums[i];
            i += 3, j += 3;
        }
        return nums[i];
    }
};